import {defHttp} from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
  list = '/journey/bsInsurancedata/list',
  save='/journey/bsInsurancedata/add',
  edit='/journey/bsInsurancedata/edit',
  deleteOne = '/journey/bsInsurancedata/delete',
  deleteBatch = '/journey/bsInsurancedata/deleteBatch',
  importExcel = '/journey/bsInsurancedata/importExcel',
  exportXls = '/journey/bsInsurancedata/exportXls',
    bsThirdinsurancelogList = '/journey/bsTravelgroupTourorderrecord/listBsThirdinsurancelogByMainId',
    bsThirdinsurancelogSave='/journey/bsTravelgroupTourorderrecord/addBsThirdinsurancelog',
    bsThirdinsurancelogEdit='/journey/bsTravelgroupTourorderrecord/editBsThirdinsurancelog',
    bsThirdinsurancelogDelete = '/journey/bsTravelgroupTourorderrecord/deleteBsThirdinsurancelog',
    bsThirdinsurancelogDeleteBatch = '/journey/bsTravelgroupTourorderrecord/deleteBatchBsThirdinsurancelog',
}
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;
/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;
/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
  defHttp.get({url: Api.list, params});

/**
 * 删除单个
 */
export const deleteOne = (params,handleSuccess) => {
  return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const batchDelete = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.edit : Api.save;
  let ext={
  	  msg:params.msg||''
  }
  params.extinfor=JSON.stringify(ext)
  
  return defHttp.post({url: url, params});
}
/**
 * 列表接口
 * @param params
 */
export const bsThirdinsurancelogList = (params) => {
  if(params['tourorderid']){
    return defHttp.get({url: Api.bsThirdinsurancelogList, params});
  }
  return Promise.resolve({});
}


/**
 * 删除单个
 */
export const bsThirdinsurancelogDelete = (params,handleSuccess) => {
  return defHttp.delete({url: Api.bsThirdinsurancelogDelete, params}, {joinParamsToUrl: true}).then(() => {
    handleSuccess();
  });
}
/**
 * 批量删除
 * @param params
 */
export const bsThirdinsurancelogDeleteBatch = (params, handleSuccess) => {
  createConfirm({
    iconType: 'warning',
    title: '确认删除',
    content: '是否删除选中数据',
    okText: '确认',
    cancelText: '取消',
    onOk: () => {
      return defHttp.delete({url: Api.bsThirdinsurancelogDeleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
        handleSuccess();
      });
    }
  });
}
/**
 * 保存或者更新
 * @param params
 */
export const  bsThirdinsurancelogSaveOrUpdate = (params, isUpdate) => {
  let url = isUpdate ? Api.bsThirdinsurancelogEdit : Api.bsThirdinsurancelogSave;
  
  
  return defHttp.post({url: url, params});
}
/**
 * 导入
 */
export const bsThirdinsurancelogImportUrl = '/journey/bsTravelgroupTourorderrecord/importBsThirdinsurancelog'

/**
 * 导出
 */
export const bsThirdinsurancelogExportXlsUrl = '/journey/bsTravelgroupTourorderrecord/exportBsThirdinsurancelog'